class Box
{
  
  color col;
  float w;
  float h;
  Body body;
  int id;
  
  Zen zen;
  int iniAlpha = 100;
  
  Box(float x, float y)
  {
    
    w = 50;
    h = 50;
    zen = new Zen(.075);
    zen.setiX(0);
    zen.setX(iniAlpha);
    col = color(zen.x());
    
    body = physics.createRect(x-w, y-h, x+w, y+h);
    Vec2 vel = new Vec2(random(-5.0f,5.0f),random(-5.0f,5.0f));
    body.setLinearVelocity(vel);
    body.setAngularVelocity(random(-.5,.5));
    body.setUserData(this);
  }
  
  
  
  void display()
  {
    /* org.jbox2d.collision.Shape shape;
     fill(255,0,0,100);
    for (shape = body.getShapeList(); shape != null; shape = shape.getNext()) 
    {
        beginShape();
      
        PolygonShape poly = (PolygonShape) shape;
      
        //get the number of vertex points that make up the shape
        int count = poly.getVertexCount();
      
        //convert the polygon into points
        Vec2[] verts = poly.getVertices();
      
        //make a vertex for each point of the polygon and convert for pixel coordinates
        for(int i = 0; i < count; i++) {
      
          //get the position of the vertex of the shape within the body in the world (whew!!)
          Vec2 vert = physics.worldToScreen(body.getWorldPoint(verts[i]));
          vertex(vert.x, vert.y);
        }
      
        //connect the last point with the first point and stop
        Vec2 firstVert = physics.worldToScreen(body.getWorldPoint(verts[0])); 
        vertex(firstVert.x, firstVert.y);
        endShape();
     
    }*/
   
  
    Vec2 pos = physics.worldToScreen(body.getPosition());
    // Get its angle of rotation
    float a = body.getAngle();

    rectMode(CENTER);
    pushMatrix();
    translate(pos.x,pos.y);
    rotate(-a);
    fill(20, zen.x());
    noStroke();
    rect(0,0,w*2,h*2);
    popMatrix();
  }
  
  
  void hit()
  {
    zen.setiX(255);
    zen.setX(iniAlpha);
    String msg = "m" + id;
    client.send(msg, 0);
    client.send(msg, 1);
    
    //String msgg = "mum";
    //client.send(msgg, random(0,1));
    
    //client.send(msg, 0);
  }
  
}
